Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limitador version from env var #37

Merged
merged 2 commits into from
Aug 22, 2022
Merged

limitador version from env var #37

merged 2 commits into from
Aug 22, 2022

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Aug 18, 2022

what

Limitador image can be read from RELATED_IMAGE_LIMITADOR env var. Defaults to quay.io/3scale/limitador:latest-

Required to specify the limitador image from the CSV manifest

spec.version will override any value from RELATED_IMAGE_LIMITADOR.

The limitador image order of preference is:

  • spec.version value (only allows tag, repo will alway be quay.io/3scale/limitador
  • value from RELATED_IMAGE_LIMITADOR env var. Image repo and tag needs to be specified. For example: quay.io/3scale/limitador:0.5.1
  • Default value: quay.io/3scale/limitador:latest

Verification steps

run cluster

make local-setup-kind

install CRDs

make install

run operator locally with specific RELATED_IMAGE_LIMITADOR env var.

RELATED_IMAGE_LIMITADOR=quay.io/3scale/limitador:0.5.1 make run

Create Limitador object without spec.version to deploy version from env var.

k apply -f - <<EOF
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
  name: limitador-sample
spec:
  limits:
    - conditions: ["get-toy == yes"]
      max_value: 2
      namespace: toystore-app
      seconds: 30
      variables: []
EOF

Check limitador's version is quay.io/3scale/limitador:0.5.1

$ k get deployment limitador-sample -o yaml | yq e '.spec.template.spec.containers[0].image' -
quay.io/3scale/limitador:0.5.1

@eguzki eguzki requested a review from didierofrivia August 18, 2022 17:57
@eguzki eguzki force-pushed the limitador-version-as-env-var branch from cf9f337 to cd8c7f7 Compare August 19, 2022 10:36
Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes make sense, we could quick discuss the minor comments I've left 👍🏼

@@ -372,6 +372,9 @@ spec:
- --leader-elect
command:
- /manager
env:
- name: RELATED_IMAGE_LIMITADOR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename it to something like LIMITADOR_SERVICE_IMAGE or LIMITADOR_INSTANCE_IMAGE or just LIMITADOR_IMAGE ... regarding the last one, we could make the distinction with LIMITADOR_OPERATOR_IMAGE if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RELATED_IMAGE prefix is commonly in OSBS for productization purposes.

I am preparing it for the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the relatedImages section in the bundle is automatically created because of that prefix is being used.

config/manager/manager.yaml Show resolved Hide resolved
@@ -64,9 +64,9 @@ func LimitadorDeployment(limitador *limitadorv1alpha1.Limitador) *appsv1.Deploym
replicas = int32(*limitador.Spec.Replicas)
}

version := DefaultVersion
image := GetLimitadorImageVersion()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you are thinking on having extra capabilities for the image and repository, but if not we could simply use FetchEnv here like:

image := helpers.FetchEnv(RELATED_IMAGE_LIMITADOR, fmt.Sprintf("%s:%s", LimitadorRepository, DefaultVersion) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only included the logic in a method to be testable in image_test.go

@eguzki eguzki merged commit d0c8bb8 into main Aug 22, 2022
@eguzki eguzki deleted the limitador-version-as-env-var branch August 22, 2022 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants